import apiClient from './client';

export interface ChinaCityTree {
  name: string;
  id: number;
  level: number;
  code: string;
  value: string;
  children: ChinaCityInfo[];
}

export interface ChinaCityInfo {
  name: string;
  id: number;
  level: number;
  parent: ChinaCityInfo;
}


/**
 * 获取中国城市行政三级区划
 * @returns 城市行政三级区划列表
 */
export const getChinaCityListApi = async (): Promise<{
  code: number;
  message: string;
  data:ChinaCityTree[];
}> => {
  return apiClient.get('/api/city/v1/region');
};

/**
 * 根据地理坐标获取城市信息
 */
export const getCityInfoByLocationApi = async (
  latitude: number, 
  longitude: number): Promise<{
  code: number;
  message: string;
  data:ChinaCityTree[];
}> => {
  return apiClient.get('/api/city/v1/location', { latitude, longitude });
};

